# -*- coding: utf-8 -*-
from django.contrib import admin
from djapp import views
from djapp.models import *
"""-----------------------------------------------------------------------------------"""
class LevelAdmin(admin.ModelAdmin):
    fieldsets = (
            (None, {'fields': ('level', 'name', 'tags')}),
        )
    list_display = ('level', 'name', 'utf_tags')
    
admin.site.register(Level, LevelAdmin)


class CategoryAdmin(admin.ModelAdmin):
    fieldsets = (
            (None, {'fields': ('header', 'wave_id', 'tags')}),
        )
    list_display = ('header', 'wave_id', 'utf_tags')
    
admin.site.register(Category, CategoryAdmin)

class TagAdmin(admin.ModelAdmin):
    fieldsets = (
            (None, {'fields': ('name', 'tags')}),
        )
    list_display = ('name', 'utf_tags')
    
admin.site.register(ExtendedTag, TagAdmin)


def list_update(sender, instance, **kwargs):
    views.printwavelist(has_changes = True, tags_updated = True)
    
models.signals.post_save.connect(list_update, sender=Level)
models.signals.post_delete.connect(list_update, sender=Level)

models.signals.post_save.connect(list_update, sender=ExtendedTag)
models.signals.post_delete.connect(list_update, sender=ExtendedTag)

models.signals.post_save.connect(list_update, sender=Category)
models.signals.post_delete.connect(list_update, sender=Category)
